<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="get">get</button>
    <button class="post">post</button>
</body>
<script type="module">
    import {ajax} from "../js/ajax.js";


    var getBtn = document.getElementsByClassName("get")[0];
    var postBtn = document.getElementsByClassName("post")[0];


    // 请求的流程
    // 1. 创建请求
    // 2. 配置请求相关信息
    // 3. 发送请求
    // 4. 绑定事件 监听服务器响应
    // 5. 获取响应数据 -> 后期处理


    var wd = "";
    var col = "id";
    var type = "asc";
    var page = 1;
    var size = 10;

    getBtn.onclick = function () {

        ajax({
            data: `wd=${wd}&col=${col}&type=${type}&page=${page}&size=${size}`,
            url: "http://121.43.116.41/demo/php/searchGradeOrderLimit.php",
            dataType: "json",
            async: true,
            success: function (res) {
                console.log("请求成功", res);
            }
        })

        ajax({
            url: "http://121.43.116.41/demo/php/searchGradeOrderLimit.php",
            data: {
                wd: wd,
                col: col,
                type,
                page,
                size,
            },
            dataType: "json",
            async: true,
            success: function (res) {
                console.log("请求成功", res);
            }
        })
    }


    postBtn.onclick = function () {
        var user = "a123123";
        var pwd = "123123";

        ajax({
            type:"post",
            url: "http://121.43.116.41/demo/php/login.php",
            // data:`user=${user}&pwd=${pwd}`,
            data: {
                user: user,
                pwd,
            },
            // async:true,
            dataType: "json",
            success: function (res) {
                console.log("请求成功", res);
            }
        })
    }


  



</script>

</html>